Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more specs for method calls with a space #1063

Merged
merged 1 commit into from
Aug 30, 2023
Merged

Add more specs for method calls with a space #1063

merged 1 commit into from
Aug 30, 2023

Conversation

fxn
Copy link
Contributor

@fxn fxn commented Aug 30, 2023

This is a question disguised as optimistic patch :).

Looks like

foo (...)

(note the space after foo) is special-cased to turn single statements into expressions without the need of extra parentheses, but mulitple statements don't have this automation.

Assuming this is intentional, this patch adds coverage for it, and a few related specs since I was on it.

@eregon eregon merged commit c91ccef into ruby:master Aug 30, 2023
10 checks passed
@fxn
Copy link
Contributor Author

fxn commented Aug 30, 2023

❤️

@fxn
Copy link
Contributor Author

fxn commented Aug 30, 2023

@eregon when we write

foo (1)

do you know what is (1) syntactically? On one hand, it is not an argument list, clearly. Looks like an expression, but if it was an expression, single and multiple statements in it would work without double parens (in particular, single statements would not need to be said to be special-cased).

What is it?

@eregon
Copy link
Member

eregon commented Aug 30, 2023

I don't, it might be this expr vs stmt rule in parse.y or so.

@eregon
Copy link
Member

eregon commented Aug 31, 2023

Maybe related: https://bugs.ruby-lang.org/issues/19281

@konsolebox
Copy link

So since YARP.parse('puts (:x; :y)').success? works and puts (:x; :y) itself in Ruby doesn't, which one is the correct behavior really?

@fxn Thanks by the way for creating this PR.

@konsolebox
Copy link

konsolebox commented Sep 1, 2023

@eregon Any chance Matz might give his thoughts about this and how () should work in general? () allowing multiple statements is pretty much undocumented.

@eregon
Copy link
Member

eregon commented Sep 4, 2023

It seems the behavior was changed in https://bugs.ruby-lang.org/issues/19281 so we'll adapt the specs based on that

@fxn
Copy link
Contributor Author

fxn commented Sep 4, 2023

OK, that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants